//=============================================================================

#ifndef AWORLD_H
  #define AWORLD_H

//=============================================================================

#include "doNet.h"
#include "doFilesWomb.h"
#include "doSurfaces.h"
#include "doLog.h"
#include "doCommon.h"
#include "aObject.h"
#include "aMage.h"

//=============================================================================

#define WORLD aWorld::awGetInstance()

//=============================================================================

class aWorld
{
  private:
    aWorld();
    ~aWorld();

  public:
    inline static aWorld& awGetInstance()               {static aWorld world; return world;}
    inline void awReceiveAction(const aActionPush& ap)  {actions.alAddItem()->data.aaPrepareAction(ap);}
    inline bool awOpenConnection()                      {if (connection.acConnectTo() != CLN_DONE) return 0; return 1;}
    inline void awAddPacketToProceed(const aPacket& p)  {packets.alAddItem()->data = p;}

    void awInit();
    void awBornWorld();
    void awWorldProcess();
    void awChewTheActions();
    void awAddMage(const unsigned char mage, const aVector& vec);
    void awProceedPackets();

  private:
    void awClearWorld();

  public:
    aString caption;

  private:
    aClient connection;
    aVector gravity;
    aList<aAction> actions;
    aGround ground;
    aList<aCharacter> chars;
    aList<aPacket> packets;

    aList<aString> magesFiles;
    aList<aMage> magesSpecimens;
    aList<aMage> mages;
    aList<unsigned long> freeIds;
    unsigned long lastId;
};

//=============================================================================

#endif

//=============================================================================
